package cn.edu.xhu.library_management.user.controller.Applets;

import cn.edu.xhu.library_management.common.entity.R;
import cn.edu.xhu.library_management.user.client.BookClient;
import cn.edu.xhu.library_management.user.entity.LmBorrow;
import cn.edu.xhu.library_management.user.entity.dto.BookRecordDTO;
import cn.edu.xhu.library_management.user.service.LmBorrowService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: MMJ
 * @Date: 2023 - 04 - 29
 * @Description: 借阅图书controller
 */
@Api(tags = "小程序模块")
@ApiSort(6)
@RestController
@RequestMapping("/lm_user/user/applet")
public class BorrowController {

    @Resource
    private BookClient bookClient;

    @PostMapping("/borrow")
    public R borrowBook(@RequestBody LmBorrow lmBorrow){
        boolean flag = bookClient.borrowBook(lmBorrow);
        return flag?R.ok("借阅成功"):R.error("借阅失败");
    }

    @GetMapping("/borrow/noRe/{account}")
    public R noReBorrow(@PathVariable("account") String account){
        return R.ok().data("noBorrowRecord",bookClient.noReBorrow(account));
    }
}
